/************************************************************************
    filename:   DaterGroupEventMap.cpp
    created:    21/5/2012
    author:     4Ys

    purpose:    Implements class for Group Event objects
*************************************************************************/
#include "DaterGroupEventMap.h"

namespace Dater
{
	GroupEventMap::GroupEventMap(int groupID, int groupEventID, User* publisher, const std::string& name,
		const Time& startTime, const Time& finishTime, const Time& createTime, const std::string& description) :
		_groupID(groupID),
		_groupEventID(groupEventID),
		_publisher(publisher),
		_name(name),
		_description(description),
		_startTime(startTime),
		_finishTime(finishTime),
		_createTime(createTime)
	{
	}

	void GroupEventMap::setState(int userID, GroupEventState state)
	{
		_relatedUserState[userID] = state;
	}

	GroupEventMap::GroupEventState GroupEventMap::getState(int userID)
	{
		if(_relatedUserState.find(userID) != _relatedUserState.end())
		{
			return _relatedUserState[userID];
		}else
		{
			return Waiting;
		}
	}

	int GroupEventMap::getGroupID()
	{
		return _groupID;
	}

	int GroupEventMap::getGroupEventID()
	{
		return _groupEventID;
	}

	const std::string& GroupEventMap::getName() const
	{
		return _name;
	}

	const std::string& GroupEventMap::getDescription() const
	{
		return _description;
	}

	const Time& GroupEventMap::getCreateTime() const
	{
		return _createTime;
	}

	const Time& GroupEventMap::getStartTime() const
	{
		return _startTime;
	}

	const Time& GroupEventMap::getFinishTime() const
	{
		return _finishTime;
	}

	void GroupEventMap::setName(const std::string& name)
	{
		_name = name;
	}

	void GroupEventMap::setDescription(const std::string& description)
	{
		_description = description;
	}

	void GroupEventMap::setCreateTime(const std::string& createTime)
	{
		_createTime = createTime;
	}

	void GroupEventMap::setStartTime(const std::string& startTime)
	{
		_startTime = startTime;
	}

	void GroupEventMap::setFinishTime(const std::string& finishTime)
	{
		_finishTime = finishTime;
	}

	
	void GroupEventMap::setPublisher(User* publisher)
	{
		_publisher = publisher;
	}

	User* GroupEventMap::getPublisher()
	{
		return _publisher;
	}

	GroupEventMap::UserStateIterator GroupEventMap::getIterator(void) const
	{
		 return UserStateIterator(_relatedUserState.begin(), _relatedUserState.end());
	}
}